<template>
  <!-- /minequestion -->
  <div class="minemessage">
    <div class="minemessage-header">
      <div class="minemessage-back" @click="gotoback">
        <van-icon name="arrow-left" />
      </div>
      <div class="minemessage-title">回答和点赞</div>
    </div>
    <div class="minemessage-content">
      <div v-if="flag" class="minemessage-content-img">
        <img src="../../public/img/community-1.png" alt="" />
        <p class="minemessage-content-img-title">还没留下记录</p>
      </div>
      <div v-else>
        <div v-for="(item, index) in ids" :key="index" class="minemessage-msg">
          <div class="minemessage-msg-img"><img src="" alt="" /></div>
          <div class="minemessage-msg-wrap">
            <div class="minemessage-msg-title">
              <span> {{ item.qtitle }}</span>
              <span class="minemessage-msg-time"> {{ item.queTime }}</span>
            </div>
            <div class="minemessage-msg-content">{{ item.qcontext }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from "vue";
export default {
  setup() {
    //判断是否有内容
    const flag = ref(true);
    //保存数据
    const ids = [JSON.parse(localStorage.getItem("qarr2"))];
    //当前时间
    return {
      flag,
      ids,
    };
  },
  methods: {
    gotoback() {
      this.$router.go(-1);
    },
  },
  created() {
    if (this.ids == false) {
      this.flag = true;
    } else {
      this.flag = false;
    }
  },
};
</script>

<style lang="less">
.minemessage-header {
  display: flex;
  background: #fff;
  box-shadow: 0px 1px 10px #888888;
  .minemessage-back {
    padding: 10px;
  }
  .minemessage-title {
    padding: 10px 0;
    font-size: 20px;
    flex: 1;
    text-align: center;
  }
}
.minemessage-content-img {
  text-align: center;
  margin-top: 100px;
}
.minemessage-content-img-title {
  color: #e0e0e0;
  font-size: 14px;
}
.minemessage-msg {
  display: flex;
  padding: 20px 10px;
  margin: 10px 0;
  background: #fff;
  .minemessage-msg-img {
    width: 50px;
    height: 50px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .minemessage-msg-wrap {
    margin-left: 10px;
    flex: 1;
    .minemessage-msg-title {
      font-size: 16px;
      margin: 5px 0;
      display: flex;
      justify-content: space-between;
      .minemessage-msg-time {
        font-size: 12px;
        color: #b5b5b5;
      }
    }
    .minemessage-msg-content {
      font-size: 14px;
    }
  }
}
</style>
